package com.zj.osm.model.dao;

import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

import com.zj.osm.model.pojo.EquipModuleType;
import com.zj.osm.utils.SQLiteDatabaseUtils;

import java.util.LinkedList;
import java.util.List;

/**
 * @author jiang zhu on 2019/10/27
 */
public class EquipModuleTypeDao {

    private static final String SELECT_FROM_EQUIP_MODULE_TYPE = "select * from equip_moduleType";
    private SQLiteDatabase sqLiteDatabase = SQLiteDatabaseUtils.getInstance().getSQLiteDatabase();


    /**
     * 获取EquipType集合
     *
     * @return /
     */
    public List<EquipModuleType> getEquipModuleTypeList() {
        //LinkedList增删快  ArrayList查询快
        List<EquipModuleType> equipTypeList = new LinkedList<>();
        Cursor cursor = sqLiteDatabase.rawQuery(SELECT_FROM_EQUIP_MODULE_TYPE, null);
        while (cursor.moveToNext()) {
            EquipModuleType equip = new EquipModuleType(
                    cursor.getInt(0),
                    cursor.getInt(1),
                    cursor.getInt(2),
                    cursor.getString(3)
            );
            equipTypeList.add(equip);
        }
        cursor.close();
        return equipTypeList;
    }


}
